import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AreasVO, AreasForm, AreasQuery } from '@/api/system/areas/types';

/**
 * 查询全国城市信息列表
 * @param query
 * @returns {*}
 */

export const listAreas = (query?: AreasQuery): AxiosPromise<AreasVO[]> => {
  return request({
    url: '/system/areas/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询全国城市信息详细
 * @param id
 */
export const getAreas = (id: string | number): AxiosPromise<AreasVO> => {
  return request({
    url: '/system/areas/' + id,
    method: 'get'
  });
};

/**
 * 新增全国城市信息
 * @param data
 */
export const addAreas = (data: AreasForm) => {
  return request({
    url: '/system/areas',
    method: 'post',
    data: data
  });
};

/**
 * 修改全国城市信息
 * @param data
 */
export const updateAreas = (data: AreasForm) => {
  return request({
    url: '/system/areas',
    method: 'put',
    data: data
  });
};

/**
 * 删除全国城市信息
 * @param id
 */
export const delAreas = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/areas/' + id,
    method: 'delete'
  });
};
